home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / glass / glass.lha / GLASS / glammar / ge23.c < prev    next >
C/C++ Source or Header  |  1991-01-21  |  3KB  |  113 lines

  1. /*
  2.  
  3.     This file is a part of the GLAMMAR source distribution 
  4.     and therefore subjected to the copy notice below. 
  5.     
  6.     Copyright (C) 1989,1990  Eric Voss, ericv@cs.kun.nl 
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation version 1
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include "ge1.h"
  22. #ifdef SET_ERRMSG
  23. set_errmsg(ntname) 
  24. char *ntname;
  25. {
  26.    if (rmax < level) {
  27.        strcpy(error_msg , ntname);
  28.        rmax = level;
  29.    }
  30. }
  31. #endif
  32.  
  33.  
  34.  
  35.  
  36. #ifdef AFXCMP
  37. #define GET_CELL_IN_STRING(cell,str)\
  38. { register char *d = (char *) & cell;\
  39.    register char *rc = str; \
  40.    d [0] = rc [1] ; d[1] = rc [2]; d [2] = rc [3];\
  41.       d[3] = rc[4];} 
  42.  
  43. afxcmp(x,y)
  44. register char * x, *y;
  45. {
  46.     if ( (x == undefined) || (y == undefined)) {
  47.         if (rmax > 1)
  48.             fprintf(stderr, "==> %d :\n", rmax);
  49.         fprintf(stderr, "Glammar message:\n\
  50.       In afxcmp (\"%s\",\"%s\"): trying to evaluate uninstantiated affix.\n",
  51.             x,y);
  52.         parsecount = 0;
  53.         errmsg();
  54.         exit (1);
  55.     }
  56.     for (; *y != '\0'; )
  57.         if (*x ==  '\001' || *x == '\002')  {
  58.             if (*x == *y)
  59.                 if ((*(x+1) == *(y+1)) &&
  60.                     (*(x+2) == *(y+2)) &&
  61.                     (*(x+3) == *(y+3)) &&
  62.                     (*(x+4) == *(y+4)) ) {
  63.                     y +=6;
  64.                     x +=6;
  65.                 }
  66.                 else if (( *x == '\001') && 
  67.                     ( *(x+5) == '\001') && 
  68.                     ( *(y+5) == '\001') ) {
  69.                     affix *ax,*ay;
  70.                     GET_CELL_IN_STRING(ax,x);
  71.                     GET_CELL_IN_STRING(ay,y);
  72.                     if (dequal(ax->l,ay ->l) &&
  73.                         dequal(ax->r,ay ->r))  {
  74.                         y +=6;
  75.                         x +=6;
  76.                     } else return 1;
  77.  
  78.                 } 
  79.                 else return 1;
  80.             else return 1;
  81.         }
  82.         else if (*x++ != *y++)
  83.             return 1;
  84.     if (*x == '\0')
  85.         return 0;
  86.     return 1;
  87. }
  88.  
  89. lexafxcmp(x,y)
  90. register char * x, *y;
  91. {
  92.    for (; *y != '\0'; )
  93.       if (*x ==  '\001' || *x == '\002')  {
  94.          if (*x == *y)
  95.             if (*(x+1) == *(y+1))
  96.                if (*(x+2) == *(y+2))
  97.                   if (*(x+3) == *(y+3))
  98.                      if (*(x+4) == *(y+4) ){
  99.                         y +=6;
  100.                         x +=6;
  101.                      }
  102.                      else return *(x+4) - *(y+4);
  103.                   else return *(x+3) - *(y+3);
  104.                else return *(x+2) - *(y+2);
  105.             else return *(x+1) - *(y+1);
  106.          else return *x - *y;
  107.       }
  108.       else if (*x++ != *y++)
  109.          return *(x-1) - *(y-1);
  110.    return *x;
  111. }
  112. #endif
  113.